package com.sojson.config.filter.interfaces.impl;

import java.io.IOException;

import com.sojson.config.filter.interfaces.KickoutFilterInterface;
import com.sojson.util.StringUtil;
import com.sojson.util.token.TokenUtil;

/**
 * 判断同一个帐号是否在多地登录 只判断已经登录的用户,没有登录直接过(允许不限制和限制)
 * 
 * @author liu
 *
 */
public class KickoutImpl implements KickoutFilterInterface {

    private static KickoutImpl kickoutOneImpl;

    private KickoutImpl() {}

    /**
     * 判断同一个帐号是否在多地登录 只判断已经登录的用户，没有登录直接过(允许不限制和限制)
     * 
     * @throws IOException
     * 
     * @throws Exception
     */
    @Override
    public void kickout() throws IOException {
        TokenUtil.kickout();
    }

    /**
     * 判断一个对象是否是空(空对象)
     * 
     * @param obj
     * @return
     */
    private static boolean isBlankObject(Object obj) {
        return StringUtil.isBlankObject(obj);
    }

    public static KickoutImpl getInstances() {
        if (isBlankObject(kickoutOneImpl)) {
            kickoutOneImpl = new KickoutImpl();
        }
        return kickoutOneImpl;
    }

}